/**
 * Created by benz on 2017/3/19.
 */
module.exports = app => {
    const Sequelize = app.Sequelize;
    return app.model.define('label', {
        id:{
            type:Sequelize.INTEGER,
            autoIncrement:true,
            allowNull:false,
            primaryKey:true,
            unique:true
        },
        name: {
            type:Sequelize.STRING,
            allowNull:false
        }

    }, {
        timestamps:true,
        paranoid:true,
        underscored: false,
        classMethods:{
            associate(){
                app.model.Label.belongsToMany(app.model.User, {through: 'article_has_label', foreignKey: 'labelId'});
            }
        }
    });
};